<?php
require './model/Db.php';
$Db = Db::getInstance();
$user_data = $Db->islogin();
if(!is_numeric($_GET['mailid'])){
	header('Location:err.php?id=5');
}
$isExist = $Db->find([
	table => [mail => 'a',bbs_user => 'b'],
	field => 'a.*,b.id uid,b.user,b.photo',
	where => "a.from_id = b.id and a.id = {$_GET['mailid']} and a.to_id = {$user_data['id']}"
])[0];
if(!$isExist){
	header('Location:err.php?id=5');
}else{
    $Db->update([
		table => 'mail',
		map => [
			is_read => 1
		],
		where => "`id` = {$_GET['mailid']}"
	]);
	$files = json_decode($isExist['file'])->path;
	$isExist = $Db->tohtml($isExist);
}
$web_title = '私信内容';
$css = [
	'public/css/my-bootstrap.min.css',
	'public/css/mailcont.all.min.css'
];
include './view/header.html';
include './view/mailcont.all.html';
include './view/footer.html';